﻿
//***********************************************************************
// * Module:   TbBstOnlineAskHandler
// * 作者:  曹荣芝
// * Modified: 2013/5/5
// * Purpose: Definition of the Class TbBstOnlineAskHandler 业务逻辑处理Handler类
// ***********************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XWG.Framework.MSException;
using XWG.Framework.AuthUtility;
using XWG.Framework.AuthEntity;
using XWG.Framework.AuthSPConst;
using XWG.Framework.AuthBLL;
using XWG.JWBST.JWBSTEntity;
using XWG.JWBST.JWBSTSPConst;
using System.Web.Script.Serialization;
using System.Data;
using XWG.Framework.Query;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using XWG.JWBST.JWBSTBLL;
using XWG.Framework;
using System.Collections;
using JWBSTAPP.CommonClass;
using XWG.Framework.IAuthority;
using System.Web.UI;
namespace JWBSTAPP.AjaxServer
{
    /// <summary>
    /// TbBstOnlineAskHandler 的摘要说明
    /// </summary>
    public class TbBstOnlineAskHandler : JWBSTAPP.CommonClass.HttpHandlerBase, System.Web.SessionState.IRequiresSessionState
    {

        #region 添加记录
        /// <summary>
        /// 添加记录
        /// </summary>
        protected void AddRecord()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            try
            {
                //对Session的处理
                var mUser = AppOrganizatiOnUserBLL.Load(context.Session["UserID"].ToString());
                var mOrg = AppOrganizatiOnBLL.Load(mUser.OrgnaId);
                TbBstOnlineAsk mTbBstOnlineAsk = new TbBstOnlineAsk();
                mTbBstOnlineAsk.Id = Guid.NewGuid().ToString(); //主键
                mTbBstOnlineAsk.Content = context.Request.Form["texContent"]; //内容
                mTbBstOnlineAsk.Name = context.Request.Form["texName"]; //姓名
                mTbBstOnlineAsk.Phone = context.Request.Form["texPhone"]; //电话
                mTbBstOnlineAsk.Email = context.Request.Form["texEmail"]; //邮箱
                mTbBstOnlineAsk.Replyname = mUser.UserName; //回复人
                mTbBstOnlineAsk.Replyunit = mOrg.OrgnaName; //回复人单位
                mTbBstOnlineAsk.Replyunitcode = mOrg.OrgnaCode; //回复人单位代码
                mTbBstOnlineAsk.Createdate = DateTime.Now;//信息添加时间
                mTbBstOnlineAsk.Replycontent = context.Request.Form["texReplycontent"]; //回复内容
                mTbBstOnlineAsk.Deltag = 0; //删除标志0未删除1已删除

                mResultModel = TbBstOnlineAskBLL.Insert(mTbBstOnlineAsk, context.Session["UserID"], true); //新建操作
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion

        #region 删除记录
        /// <summary>
        /// 删除记录
        /// </summary>
        protected void DeleteRecord()
        {

            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //声明返回类型
            try
            {
                string[] arryParamKey = context.Request.Params["id"].ToString().Split(',');
                if (arryParamKey.Length == 0)
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                TbBstOnlineAsk mTbBstOnlineAsk = new TbBstOnlineAsk();
                foreach (var paramKey in arryParamKey)
                {
                    mResultModel = TbBstOnlineAskBLL.Delete(paramKey, context.Session["UserID"], true); //删除对应的信息
                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); ; //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, ""); //写入异常日志
                mResultModel.ErrorCode = -9999; //-9999代码是系统异常通用代码
                mResultModel.ISSucceed = false; //行为执行失败
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }

        }
        #endregion

        #region 修改记录
        /// <summary>
        /// 修改记录
        /// </summary>
        protected void EditRecord()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            TbBstOnlineAsk mTbBstOnlineAsk = new TbBstOnlineAsk();

            string paramKey = context.Request.Params["id"];
            try
            {

                if (string.IsNullOrEmpty(paramKey))
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                mTbBstOnlineAsk = TbBstOnlineAskBLL.Load(paramKey); //根据键值获取实体信息
                if (mTbBstOnlineAsk != null)
                {
                    //对Session的处理
                    var mUser = AppOrganizatiOnUserBLL.Load(context.Session["UserID"].ToString());
                    var mOrg = AppOrganizatiOnBLL.Load(mUser.OrgnaId);
                    mTbBstOnlineAsk.Content = context.Request.Form["texContent"]; //内容
                    mTbBstOnlineAsk.Name = DES.Encode(context.Request.Form["texName"]); //姓名
                    // mTbBstOnlineAsk.Phone = DES.Encode(context.Request.Form["texPhone"]); //电话
                    mTbBstOnlineAsk.Email = DES.Encode(context.Request.Form["texEmail"]); //邮箱
                    mTbBstOnlineAsk.Category = context.Request.Form["selCategory"];//警种
                    mTbBstOnlineAsk.Replydate = DateTime.Now; //回复时间
                    mTbBstOnlineAsk.Replyname = mUser.UserName; //回复人
                    mTbBstOnlineAsk.Replyunit = mOrg.OrgnaName; //回复人单位
                    mTbBstOnlineAsk.Replyunitcode = mOrg.OrgnaCode; //回复人单位代码
                    mTbBstOnlineAsk.Replycontent = context.Request.Form["texReplycontent"]; //回复内容
                    mTbBstOnlineAsk.Deltag = 0; //删除标志0未删除1已删除


                    mResultModel = TbBstOnlineAskBLL.Update(mTbBstOnlineAsk, context.Session["UserID"], true); //新建操作
                }
                else
                {
                    mResultModel.ErrorCode = -9990; //没有获取所需的信息，信息可能已被删除
                    mResultModel.ISSucceed = false;

                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion

        #region 获取实体记录
        /// <summary>
        /// 获取实体记录
        /// </summary>
        protected void GetModel()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            string paramKey = context.Request.Params["id"];
            string json = "";
            try
            {
                TbBstOnlineAsk mTbBstOnlineAsk = new TbBstOnlineAsk(); //声明实体
                TbBstDic mTbBstDic = new TbBstDic();
                if (!string.IsNullOrEmpty(paramKey))
                {
                    mTbBstOnlineAsk = TbBstOnlineAskBLL.Load(paramKey); //根据键值获取管理员
                    if (mTbBstOnlineAsk != null)
                    {
                        if (mTbBstOnlineAsk.Replydate.ToString("yyyy") == "0001")
                        {
                            mTbBstOnlineAsk.Replydatestr = "暂无回复";
                        }
                        else
                        {
                            mTbBstOnlineAsk.Replydatestr = mTbBstOnlineAsk.Replydate.ToString("yyyy-MM-dd HH:mm:ss");
                        }
                        ////未回复时把回复人、回复内容 改成暂无回复
                        if (mTbBstOnlineAsk.ReplySign == 0)
                        {
                            mTbBstOnlineAsk.Replynamestr = "暂无回复";
                            mTbBstOnlineAsk.Replycontentstr = "暂无回复";
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(mTbBstOnlineAsk.Replycontent))
                            {
                                mTbBstOnlineAsk.Replycontent = "";
                            }
                            else
                            {
                                mTbBstOnlineAsk.Replycontentstr = mTbBstOnlineAsk.Replycontent.ToString();
                            }
                            mTbBstOnlineAsk.Replynamestr = mTbBstOnlineAsk.Replyname.ToString();
                        }
                        ////数据库部分加密字段解密
                        mTbBstOnlineAsk.Name = DES.Decode(mTbBstOnlineAsk.Name);
                        mTbBstOnlineAsk.Phone = DES.Decode(mTbBstOnlineAsk.Phone);
                        mTbBstOnlineAsk.Email = DES.Decode(mTbBstOnlineAsk.Email);
                        IsoDateTimeConverter dtConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
                        json = JsonConvert.SerializeObject(mTbBstOnlineAsk, dtConverter);

                        ////解析回复状态
                        if (!String.IsNullOrEmpty(mTbBstOnlineAsk.ReplySign.ToString()))
                        {
                            var list = TbBstDicBLL.GetDicByCodeAndParentnode(mTbBstOnlineAsk.ReplySign.ToString(), "reply");
                            mTbBstDic = list.FirstOrDefault();
                            Hashtable hashtable = new Hashtable();
                            if (mTbBstDic != null)
                            {
                                hashtable.Add("VReplySign", mTbBstDic.Description);
                                json = JsonString.AddAttribute(json, hashtable);
                            }
                        }
                        ////解析审核状态
                        if (!String.IsNullOrEmpty(mTbBstOnlineAsk.AuditSign.ToString()))
                        {
                            var list = TbBstDicBLL.GetDicByCodeAndParentnode(mTbBstOnlineAsk.AuditSign.ToString(), "audit");
                            mTbBstDic = list.FirstOrDefault();
                            Hashtable hashtable = new Hashtable();
                            if (mTbBstDic != null)
                            {
                                hashtable.Add("VAuditSign", mTbBstDic.Description);
                                json = JsonString.AddAttribute(json, hashtable);
                            }
                        }
                        ////解析咨询警种
                        if (!String.IsNullOrEmpty(mTbBstOnlineAsk.Category.ToString()))
                        {
                            var list = TbBstDicBLL.GetDicByCodeAndParentnode(mTbBstOnlineAsk.Category.ToString(), "JZ");
                            mTbBstDic = list.FirstOrDefault();
                            Hashtable hashtable = new Hashtable();
                            if (mTbBstDic != null)
                            {
                                hashtable.Add("Policekind", mTbBstDic.Description);
                                json = JsonString.AddAttribute(json, hashtable);
                            }
                        }

                    }
                }
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9990;
                mResultModel.ISSucceed = false;
                json = JsonConvert.SerializeObject(mResultModel);
            }
            context.Response.Write(json);
        }
        #endregion

        #region 获取数据
        /// <summary>
        /// 获取数据记录
        /// </summary>
        protected void QueryRecord()
        {
            TableMessage tm = new TableMessage();
            HearderMessage hm = new HearderMessage();
            List<HearderMessage> list = new List<HearderMessage>();
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            string ZJ = null;
            string pageSize = context.Request.Form["pageSize"];
            string pageIndex = context.Request.Form["pageIndex"];
            string name = DES.Encode(context.Request.Form["texName"]);////咨询人
            string phone = DES.Encode(context.Request.Form["texPhone"]);////咨询人手机
            string reply = context.Request.Form["selReply"];////回复状态
            string code = context.Request.Form["selCode"];////审核状态
            string Lsh = context.Request.Form["texLsh"];//流水号
            string timeStart = context.Request.Form["texTimeStart"]; ////添加时间-开始
            string timeEnd = context.Request.Form["texTimeEnd"]; ////添加时间-结束
            if (HttpContext.Current.Request.QueryString["ZJ"] == "null")
            {
                ZJ = null;
            }
            else
            {
                ZJ = HttpContext.Current.Request.QueryString["ZJ"];
            }
            if (String.IsNullOrEmpty(pageSize) || String.IsNullOrEmpty(pageIndex) || !AnyString.IsNumeric(pageSize) || !AnyString.IsNumeric(pageIndex))
                return;
            DataTable dtTbBstOnlineAsk = new DataTable();
            int intPageSize = Convert.ToInt32(pageSize);
            int intPageIndex = Convert.ToInt32(pageIndex);
            QueryByPage Q = new QueryByPage();
            SqlConditionList sqllist = new SqlConditionList();
            string sqlWhere = " deltag=0 ";

            if (!string.IsNullOrEmpty(Lsh))
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstOnlineAskConst.Columns.Lsh, Lsh), SqlLogicOper.AND_LOGIC);
            }

            if (!string.IsNullOrEmpty(name)) ////咨询人
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstOnlineAskConst.Columns.Name, name), SqlLogicOper.AND_LOGIC);
            }

            if (!string.IsNullOrEmpty(ZJ)) ////警种
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstOnlineAskConst.Columns.Category, ZJ), SqlLogicOper.AND_LOGIC);
            }

            if (!string.IsNullOrEmpty(phone)) ////咨询人手机
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstOnlineAskConst.Columns.Phone, phone), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(reply)) ////回复状态
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstOnlineAskConst.Columns.ReplySign, reply), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(code)) ////审核状态
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstOnlineAskConst.Columns.AuditSign, code), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(timeStart)) ////添加时间-开始
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_LESS_THAN, TbBstOnlineAskConst.Columns.Createdate, Convert.ToDateTime(timeStart)), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(timeEnd)) ////添加时间-结束
            {
                sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.NOT_MORE_THAN, TbBstOnlineAskConst.Columns.Createdate, Convert.ToDateTime(timeEnd)), SqlLogicOper.AND_LOGIC);
            }
            #region 获取警种  Add By Winter 2013-5-6
            Authority iAuth = new Authority();
            var ruleList = iAuth.SelectUserDataRulePermissionByCode(Global.AreaID, "POLICE_KINDS_RULE", context.Session["UserID"].ToString());
            if (ruleList == null || ruleList.Count() == 0)
            {

            }
            else
            {
                if (ruleList.Count() == 1)
                {
                    ///返回数组如果是一个，并且是all的话，显示全部内容
                    ///如果不是all，则有可能只有一个警种权限
                    if (ruleList[0].ToString().ToLower() != "all")
                    {
                        sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, TbBstOnlineAskConst.Columns.Category, ruleList[0].ToString()), SqlLogicOper.AND_LOGIC);
                    }
                }
                else
                {
                    sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.IN, TbBstOnlineAskConst.Columns.Category, ruleList), SqlLogicOper.AND_LOGIC);
                }
            }
            #endregion
            if (string.IsNullOrEmpty(sqllist.ToSql()))
            {
                sqlWhere = "where" + sqlWhere;
            }
            else
            {
                sqlWhere = sqllist.ToSql() + " and " + sqlWhere;
            }
            //dtTbBstOnlineAsk = Q.GetRecordByPage("ID,LSH,CONTENT,VREPLYSIGN,VAUDITSIGN,POLICEKIND,CREATEDATE", sqlWhere, "CREATEDATE", intPageSize, intPageIndex, TbBstOnlineAskConst.QTableName, TbBstOnlineAskConst.FieldKey, Sort.ASC).Tables[0];
            dtTbBstOnlineAsk = Q.GetRecordByPage("ID,LSH,DAYS,CONTENT,VREPLYSIGN,VAUDITSIGN,POLICEKIND,CREATEDATE", sqlWhere, "REPLYSIGN,CREATEDATE", intPageSize, intPageIndex, TbBstOnlineAskConst.QTableName, TbBstOnlineAskConst.FieldKey, "asc,DESC").Tables[0];
            if (dtTbBstOnlineAsk != null && dtTbBstOnlineAsk.Rows.Count > 0)
            {

                for (int i = 0; i < dtTbBstOnlineAsk.Rows.Count; i++)
                {
                    var color = "";
                    var color1 = "";
                    if (dtTbBstOnlineAsk.Rows[i]["VAUDITSIGN"].ToString() == "隐藏")
                    {
                        color = "FF0000";
                    }
                    else
                    {
                        color = "32C904";
                    }
                    dtTbBstOnlineAsk.Rows[i]["VAUDITSIGN"] = "<span style=\"color:#" + color + "\">" + dtTbBstOnlineAsk.Rows[i]["VAUDITSIGN"] + "</span>";

                    if (dtTbBstOnlineAsk.Rows[i]["VREPLYSIGN"].ToString() == "未回复")
                    {
                        color1 = "FF0000";
                    }
                    else
                    {
                        color1 = "32C904";
                    }
                    dtTbBstOnlineAsk.Rows[i]["VREPLYSIGN"] = "<span style=\"color:#" + color1 + "\">" + dtTbBstOnlineAsk.Rows[i]["VREPLYSIGN"] + "</span>";
                    if (dtTbBstOnlineAsk.Rows[i]["CONTENT"].ToString().Length > 51)
                    {
                        dtTbBstOnlineAsk.Rows[i]["CONTENT"] = dtTbBstOnlineAsk.Rows[i]["CONTENT"].ToString().Substring(0, 50) + "...";
                    }
                }

                for (int i = 0; i < dtTbBstOnlineAsk.Columns.Count; i++)
                {
                    hm = new HearderMessage();
                    hm.name = dtTbBstOnlineAsk.Columns[i].Caption;
                    list.Add(hm);
                }
                tm.Header = list;
                tm.data = dtTbBstOnlineAsk;
                tm.totalCount = Convert.ToString((int)Q.RowCount);
            }
            ////解密部分加密字段
            //for (int i = 0; i < dtTbBstOnlineAsk.Rows.Count; i++)
            //{
            //    dtTbBstOnlineAsk.Rows[i][TbBstOnlineAskConst.Columns.Phone] = DES.Decode(dtTbBstOnlineAsk.Rows[i][TbBstOnlineAskConst.Columns.Phone].ToString());
            //    dtTbBstOnlineAsk.Rows[i][TbBstOnlineAskConst.Columns.Name] = DES.Decode(dtTbBstOnlineAsk.Rows[i][TbBstOnlineAskConst.Columns.Name].ToString());
            //}
            IsoDateTimeConverter dtConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
            string json = JsonConvert.SerializeObject(tm, dtConverter);
            context.Response.Write(json);
        }
        #endregion

        #region 回复记录
        /// <summary>
        /// 回复记录
        /// </summary>
        protected void ReplyRecord()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            TbBstOnlineAsk mTbBstOnlineAsk = new TbBstOnlineAsk();

            string paramKey = context.Request.Params["id"];
            try
            {

                if (string.IsNullOrEmpty(paramKey))
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                mTbBstOnlineAsk = TbBstOnlineAskBLL.Load(paramKey); //根据键值获取实体信息
                if (mTbBstOnlineAsk != null)
                {
                    //对Session的处理
                    var mUser = AppOrganizatiOnUserBLL.Load(context.Session["UserID"].ToString());
                    var mOrg = AppOrganizatiOnBLL.Load(mUser.OrgnaId);
                    mTbBstOnlineAsk.Replydate = DateTime.Now; //回复时间
                    mTbBstOnlineAsk.Replyname = mUser.UserName; //回复人
                    mTbBstOnlineAsk.Replyunit = mOrg.OrgnaName; //回复人单位
                    mTbBstOnlineAsk.Replyunitcode = mOrg.OrgnaCode; //回复人单位代码
                    mTbBstOnlineAsk.Replycontent = context.Request.Form["texReplycontent"]; //回复内容
                    mTbBstOnlineAsk.ReplySign = 1;
                    mResultModel = TbBstOnlineAskBLL.Update(mTbBstOnlineAsk, context.Session["UserID"], true); //新建操作
                }
                else
                {
                    mResultModel.ErrorCode = -9990; //没有获取所需的信息，信息可能已被删除
                    mResultModel.ISSucceed = false;

                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion

        #region 审核记录
        /// <summary>
        /// 审核记录
        /// </summary>
        protected void AuditRecord()
        {

            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //声明返回类型
            try
            {
                string[] arryParamKey = context.Request.Params["id"].ToString().Split(',');
                if (arryParamKey.Length == 0)
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                foreach (var paramKey in arryParamKey)
                {
                    var mTbBstOnlineAsk = TbBstOnlineAskBLL.Load(paramKey); //根据键值获取管理员
                    if (mTbBstOnlineAsk.ReplySign == 0)
                    {
                        // 添加警告框提示：未回复不能审核！
                        mResultModel.ErrorCode = -998;
                    }

                    else
                    {
                        mTbBstOnlineAsk.AuditSign = 1;
                        mResultModel = TbBstOnlineAskBLL.Update(mTbBstOnlineAsk, context.Session["UserID"], true); //新建操作
                    }
                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); ; //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, ""); //写入异常日志
                mResultModel.ErrorCode = -9999; //-9999代码是系统异常通用代码
                mResultModel.ISSucceed = false; //行为执行失败
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }

        }
        #endregion

        #region 撤销审核记录
        /// <summary>
        /// 审核记录
        /// </summary>
        protected void RevocationRecord()
        {

            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //声明返回类型
            try
            {
                string[] arryParamKey = context.Request.Params["id"].ToString().Split(',');
                if (arryParamKey.Length == 0)
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                foreach (var paramKey in arryParamKey)
                {
                    var mTbBstOnlineAsk = TbBstOnlineAskBLL.Load(paramKey); //根据键值获取管理员

                    mTbBstOnlineAsk.AuditSign = 0;
                    mResultModel = TbBstOnlineAskBLL.Update(mTbBstOnlineAsk, context.Session["UserID"], true); //新建操作
                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); ; //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, ""); //写入异常日志
                mResultModel.ErrorCode = -9999; //-9999代码是系统异常通用代码
                mResultModel.ISSucceed = false; //行为执行失败
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }

        }
        #endregion

        #region 移交记录
        /// <summary>
        /// 移交记录
        /// </summary>
        protected void TransferRecord()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            TbBstOnlineAsk mTbBstOnlineAsk = new TbBstOnlineAsk();

            string paramKey = context.Request.Params["id"];
            try
            {

                if (string.IsNullOrEmpty(paramKey))
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                mTbBstOnlineAsk = TbBstOnlineAskBLL.Load(paramKey); //根据键值获取实体信息
                if (mTbBstOnlineAsk != null)
                {
                    if (mTbBstOnlineAsk.AuditSign == 0 && mTbBstOnlineAsk.ReplySign == 0)
                    {
                        var mUser = AppOrganizatiOnUserBLL.Load(context.Session["UserID"].ToString());
                        var mOrg = AppOrganizatiOnBLL.Load(mUser.OrgnaId);
                        mTbBstOnlineAsk.Category = context.Request.Form["Category"];//警种
                        mTbBstOnlineAsk.Deltag = 0; //删除标志0未删除1已删除
                        mResultModel = TbBstOnlineAskBLL.Update(mTbBstOnlineAsk, context.Session["UserID"], true); //新建操作
                    }
                    else
                    {
                        mResultModel.ErrorCode = -1;
                        mResultModel.ISSucceed = false;
                        mResultModel.Message = "已回复或已审核的信息不允许移交";
                        // JsonConvert.SerializeObject(mResultModel);
                    }
                }
                else
                {
                    mResultModel.ErrorCode = -9990; //没有获取所需的信息，信息可能已被删除
                    mResultModel.ISSucceed = false;

                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion

        #region 设为常见问题
        /// <summary>
        /// 设为常见问题
        /// </summary>
        protected void SetCjwt()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            TbBstOnlineAsk mTbBstOnlineAsk = new TbBstOnlineAsk();

            string paramKey = context.Request.Params["id"];
            try
            {

                if (string.IsNullOrEmpty(paramKey))
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                mTbBstOnlineAsk = TbBstOnlineAskBLL.Load(paramKey); //根据键值获取实体信息
                if (mTbBstOnlineAsk != null)
                {
                    mTbBstOnlineAsk.IsCjwt = "1";
                    mResultModel = TbBstOnlineAskBLL.Update(mTbBstOnlineAsk, context.Session["UserID"], true);
                    mResultModel.ISSucceed = true;
                    mResultModel.Message = "设置成功";
                    // JsonConvert.SerializeObject(mResultModel);
                }
                else
                {
                    mResultModel.ErrorCode = -9990; //没有获取所需的信息，信息可能已被删除
                    mResultModel.ISSucceed = false;

                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion
    }
}


